package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PersonPoliceCaseInfo;
import com.ruoyi.system.service.IPersonPoliceCaseInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公民报案信息Controller
 * 
 * @author TYF
 * @date 2023-08-13
 */
@Controller
@RequestMapping("/system/policeInfo")
public class PersonPoliceCaseInfoController extends BaseController
{
    private String prefix = "system/policeInfo";

    @Autowired
    private IPersonPoliceCaseInfoService personPoliceCaseInfoService;

    @RequiresPermissions("system:policeInfo:view")
    @GetMapping()
    public String policeInfo()
    {
        return prefix + "/policeInfo";
    }

    /**
     * 查询公民报案信息列表
     */
    @RequiresPermissions("system:policeInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PersonPoliceCaseInfo personPoliceCaseInfo)
    {
        startPage();
        List<PersonPoliceCaseInfo> list = personPoliceCaseInfoService.selectPersonPoliceCaseInfoList(personPoliceCaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出公民报案信息列表
     */
    @RequiresPermissions("system:policeInfo:export")
    @Log(title = "公民报案信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PersonPoliceCaseInfo personPoliceCaseInfo)
    {
        List<PersonPoliceCaseInfo> list = personPoliceCaseInfoService.selectPersonPoliceCaseInfoList(personPoliceCaseInfo);
        ExcelUtil<PersonPoliceCaseInfo> util = new ExcelUtil<PersonPoliceCaseInfo>(PersonPoliceCaseInfo.class);
        return util.exportExcel(list, "公民报案信息数据");
    }

    /**
     * 新增公民报案信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存公民报案信息
     */
    @RequiresPermissions("system:policeInfo:add")
    @Log(title = "公民报案信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PersonPoliceCaseInfo personPoliceCaseInfo)
    {
        return toAjax(personPoliceCaseInfoService.insertPersonPoliceCaseInfo(personPoliceCaseInfo));
    }

    /**
     * 修改公民报案信息
     */
    @RequiresPermissions("system:policeInfo:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PersonPoliceCaseInfo personPoliceCaseInfo = personPoliceCaseInfoService.selectPersonPoliceCaseInfoById(id);
        mmap.put("personPoliceCaseInfo", personPoliceCaseInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存公民报案信息
     */
    @RequiresPermissions("system:policeInfo:edit")
    @Log(title = "公民报案信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PersonPoliceCaseInfo personPoliceCaseInfo)
    {
        return toAjax(personPoliceCaseInfoService.updatePersonPoliceCaseInfo(personPoliceCaseInfo));
    }

    /**
     * 删除公民报案信息
     */
    @RequiresPermissions("system:policeInfo:remove")
    @Log(title = "公民报案信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(personPoliceCaseInfoService.deletePersonPoliceCaseInfoByIds(ids));
    }
}
